﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ART.BLL;
using ART.Common;
using ART.Model;

namespace ART.Admini.Users
{
    public partial class setAdmPwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnAdd.Text = "· 修改 ·";
                txtUserName.Text = BLL.B_TBAdmin.UserName;
                lblpwd.Text = "不修改请密码留空！";
                txtUserName.Attributes.Add("readonly", "true");
            }
        }
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                BLL.B_TBAdmin blluser = new B_TBAdmin();
                M_TBAdmin info = blluser.GetModel(BLL.B_TBAdmin.AId);
                info.UserName = txtUserName.Text;
                if (txtPassword.Text.Length > 2)
                {
                    info.PassWord = Utils.SHA256(txtPassword.Text);
                }
                blluser.Update(info);
                MessageBox.AlertToUrl(sender, "修改用户密码成功", "setAdmPwd.aspx");
            }

        }
    }
}
